package com.hangzhou.xyj.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.hangzhou.xyj.ui.fragment.AlreadyDianFragment;
import com.hangzhou.xyj.ui.fragment.DianDramaStageFragment;
import com.hangzhou.xyj.ui.fragment.MyRecordFragment;

/**
 * Created by DT-038 on 2015/12/22.
 * 唱戏点戏栏目tab切换adapter
 */
public class SingDramaAdapter extends FragmentPagerAdapter {
    private final String[] mTitles = {
            "点戏台",
            "已点戏曲",
            "我的录音",
    };
    private DianDramaStageFragment mStageFragment;
    private AlreadyDianFragment mAlreadyFragment;
    private MyRecordFragment mHotspotFragment;

    public SingDramaAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        switch (position) {
            case 0:
                if (mStageFragment == null) {
                    mStageFragment = new DianDramaStageFragment();
                }
                return mStageFragment;
            case 1:
                if (mAlreadyFragment == null) {
                    mAlreadyFragment = new AlreadyDianFragment();
                }
                return mAlreadyFragment;
            case 2:
            default:
                if (mHotspotFragment == null) {
                    mHotspotFragment = new MyRecordFragment();
                }
                return mHotspotFragment;
        }
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
